{
LANG : PASCAL
PROB : calfflac
}

program CALFFLAC;
{$i extime.inc}
const
  fi = 'calfflac.in';
  fo = 'calfflac.out';
  letters : set of char = ['A'..'Z', 'a'..'z'];
  maxc = 21000;
  limit = 950;
type
  xau = record
          l : longint;
          c : array[1..maxc] of char;
        end;
var
  s, a : xau;
  ID : array[1..maxc] of longint;
  best, start, finish : longint;

procedure initxau;
begin
  s.l := 0;
  a.l := 0;
end;

procedure inp;
var
  i : longint;
begin
  initxau;
  with s do
    while not eof do
    begin
      while not eoln do
      begin
        inc(l);
        read(c[l]);
        if c[l] in letters then
        begin
          inc(a.l);
          a.c[a.l] := upcase(c[l]);
          ID[a.l] := l;
        end;
      end;
      inc(l);
      c[l] := '$';
      readln;
    end;
end;

function ok(i, j, k : longint) : boolean;
var
  u, v : longint;
begin
  ok := false;
  with a do
    for u := i to i + k div 2 - 1 do
    begin
      v := i+k-1 - u + i;
      if c[u] <> c[v] then exit;
    end;
  ok := true;
end;

procedure update(i, j, k : longint);
begin
  start := ID[i];
  finish := ID[j];
  best := k;
end;

function min(x, y : longint) : longint;
begin
  if x > y then min := y
  else min := x;
end;

procedure process;
var
  i, j, k : longint;
begin
  update(1, 1, 1);
  i := 1;
  while i < a.l-best do
  begin
    k := min(2000, a.l-i+1);
    j := i+k-1;
    if exectime >= limit then exit;
    while k > best do
    begin
      if ok(i, j, k) then
      begin
        update(i, j, k);
        break;
      end;
      dec(k);
      dec(j);
    end;
    inc(i);
  end;
end;

procedure out;
var
  i : longint;
begin
  writeln(best);
  with s do
    for i := start to finish do
      if c[i] = '$' then writeln
      else write(c[i]);
  writeln;
end;

begin
  assign(input, fi); reset(input);
  assign(output, fo); rewrite(output);
  inp;
  process;
  out;
  close(output);
  close(input);
end.